package com.example.liumengqiang.mvvmoneproject.one;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.liumengqiang.mvvmoneproject.R;
import com.example.liumengqiang.mvvmoneproject.databinding.TestOneFragmentBinding;



public class TestOneFragment extends Fragment{

    private TestOneViewModel viewModel;

    public static TestOneFragment newInstance() {

        Bundle args = new Bundle();

        TestOneFragment fragment = new TestOneFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.test_one_fragment, null, false);

        TestOneFragmentBinding bind = TestOneFragmentBinding.bind(view);
        //给XML设置View和ViewModel.
        bind.setView(this);
        bind.setViewModel(viewModel);

        viewModel.onStart();

        return view;
    }

    public void setViewModel(TestOneViewModel viewModel) {
        this.viewModel = viewModel;
    }
}
